package com.zone.gateway.core.datasource.connection;

import com.zone.gateway.core.datasource.Connection;
import org.apache.dubbo.config.ReferenceConfig;
import org.apache.dubbo.rpc.service.GenericService;

/**
 * @author: zongzi
 * @description: dubbo 泛化调用
 * @date: 2025/4/21
 */
public class DubboConnection implements Connection {
    private final ReferenceConfig<GenericService> referenceConfig;

    public DubboConnection(ReferenceConfig<GenericService> referenceConfig) {
        this.referenceConfig = referenceConfig;
    }

    @Override
    public Object execute(String methodName, String[] paramsTypes, Object[] args) {
        GenericService genericService = referenceConfig.get();
        return genericService.$invoke(methodName, paramsTypes, args);
    }
}
